package com.example.drools.model;

/**
 * 价格调整结果模型
 */
public class PriceAdjustment {
    private String userId;
    private String adjustmentType;  // 调整类型：VIP_DISCOUNT, BULK_DISCOUNT等
    private double multiplier;      // 价格倍数：0.8表示8折，1.1表示涨价10%
    private String description;     // 调整描述

    public PriceAdjustment() {}

    public PriceAdjustment(String userId, String adjustmentType, double multiplier, String description) {
        this.userId = userId;
        this.adjustmentType = adjustmentType;
        this.multiplier = multiplier;
        this.description = description;
    }

    // Getters and Setters
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getAdjustmentType() {
        return adjustmentType;
    }

    public void setAdjustmentType(String adjustmentType) {
        this.adjustmentType = adjustmentType;
    }

    public double getMultiplier() {
        return multiplier;
    }

    public void setMultiplier(double multiplier) {
        this.multiplier = multiplier;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * 计算调整后的价格
     */
    public double calculateAdjustedPrice(double originalPrice) {
        return originalPrice * multiplier;
    }

    /**
     * 获取折扣百分比（仅当multiplier < 1时）
     */
    public int getDiscountPercentage() {
        if (multiplier < 1.0) {
            return (int) Math.round((1.0 - multiplier) * 100);
        }
        return 0;
    }

    @Override
    public String toString() {
        return "PriceAdjustment{" +
                "userId='" + userId + '\'' +
                ", adjustmentType='" + adjustmentType + '\'' +
                ", multiplier=" + multiplier +
                ", description='" + description + '\'' +
                '}';
    }
}